package com.hook3.pianke.activity.base.radiouserbasepager.PrivateRadioViewpagerBase;

import android.app.Activity;
import android.graphics.Bitmap;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.hook3.pianke.R;
import com.hook3.pianke.domain.RadioPlayerViewPagerInfo;

/**
 * Created by HOME on 2015/12/11.
 */
public class PrivateRadioViewpager3 extends PrivateRadioViewpagerBasePager {

    RadioPlayerViewPagerInfo radioPlayerViewPagerInfo;
    public PrivateRadioViewpager3(Activity activity, RadioPlayerViewPagerInfo radioPlayerViewPagerInfo){
        super(activity);
        this.radioPlayerViewPagerInfo = radioPlayerViewPagerInfo;
    }
    WebView webView;
    @Override
    public View initView() {
        View view = View.inflate(activity, R.layout.private_radio_viewpager3,null);
        webView = (WebView) view.findViewById(R.id.wv_private_radio_webview);
        return view;
    }

    public void initData(){
        String url = radioPlayerViewPagerInfo.getData().getPlayInfo().getWebview_url();
        WebSettings settings = webView.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setBuiltInZoomControls(true);
        webView.setWebViewClient(new WebViewClient() {
            @Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {
                super.onPageStarted(view, url, favicon);
            }

            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
            }

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl("http://www.baidu.com");
                return true;
            }
        });

        webView.loadUrl(url);
    }
}
